/*
	ChibiOS-NRF-Driver - Copyright (C) 2012
				Joel Bodenmann aka Tectu <joel@unormal.org>
				Paul Honig aka Ranzbak <paul@swarmtv.nl>
	
	This file is part of ChibiOS-NRF-Driver.

	ChibiOS-NRF-Driver is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	ChibiOS-NRF-Driver is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/*
 * @file	nrf_lld.h
 * @brief	NRF driver subsystem low level header.
 *
 * @addgroup NRF
 * @{
 */

#ifndef NRF_LLD_H
#define NRF_LLD_H

#include "ch.h"
#include "hal.h"

typedef struct _NRFDriver NRFDriver;

struct _NRFDriver {
	SPIDriver *spip;			/* pointer to SPI Driver */
	SPIConfig *spicfg;			/* pointer to SPI config */
	ioportid_t nrfCEPort;		/* port of CE */
	ioportmask_t nrfCEPin;		/* pin of CE */
	ioportid_t nrfIRQPort;		/* port of IRQ */
	ioportmask_t nrfIRQPin;		/* pin of IRQ */
};

/*
 * @brief			Inizialises the module
 *
 * @notapi
 */
void lld_nrfInit(NRFDriver *nrf);

/*
 * @brief			Write a single byte to a register
 *
 * @param[in] reg	address of register
 * @param[in] valu	value to be written to reg
 *
 * @notapi
 */
void lld_nrfWriteReg(uint8_t reg, uint8_t val);

/*
 * @brief			Reads the current value of a register
 *
 * @param[in] reg	address of the register
 *
 * @return			current value of register
 *
 * @notapi
 */
uint8_t lld_nrfReadReg(uint8_t reg);

/*
 * @brief			Writes a stream of values to a register
 *
 * @param[in] reg	address of register
 * @param[in] val	pointer to first value
 * @param[in] size	amount of values
 *
 * @notapi
 */
void lld_nrfWriteStream(uint8_t reg, uint8_t val[], uint8_t size);

#endif /* NRF_LLD_H */
/** @} */

